package itesm.coler.service;

import java.sql.SQLException;
import java.util.ArrayList;

import itesm.coler.models.Autenticator;
import itesm.coler.models.MessageCategory; 
import itesm.coler.models.User;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import itesm.coler.data.DAOFactory;
import itesm.coler.data.MessageCategoryDAO;


@Produces({"application/xml", "application/json"})
@Path("/messagecategory")
public class MessageCategoryResource {

	DAOFactory MySQLFactory = DAOFactory.getDAOFactory(DAOFactory.MySQL);
	// Create a DAO
	MessageCategoryDAO MessageCategoryDAO = MySQLFactory.getMessageCategoryDAO();
	
	 @GET
	 public ArrayList<MessageCategory> getMessageCategories() throws SQLException {
		  
		 System.out.println("Voy a hacer consulta MessageCategory");
		 return MessageCategoryDAO.findAll();
	 }
	 
	 @GET
	 @Path("/categoryId/{categoryId}/")
	 @Produces({ "application/xml", "application/json" })
	 public MessageCategory getMessageCategoryById(@PathParam("categoryId") String categoryId) {
	    MessageCategory messageCategory = null;
	    messageCategory = (MessageCategory) MessageCategoryDAO.findMessageCategoryByMessageCategoryId(categoryId);
	    return messageCategory;
	 }
	 
}
